<?php
/**
 * Created by PhpStorm.
 * User: iceberg
 * Date: 2018-10-12
 * Time: 14:40
 */

namespace app\system\controller;


use app\service\UserService;
use think\Controller;

class User extends Controller
{
    //用户业务
    private $userService;

    //初始化方法
    public function initialize()
    {
        $this->userService = new UserService();
    }

    //列表
    public function index()
    {
        $this->assign('list', $this->userService->page());
        $this->assign('count', $this->userService->count());
        return $this->fetch();
    }

    //创建
    public function create()
    {
        $this->assign('roles', config("rbac.RBAC_ROLES"));
        return $this->fetch();
    }

    //保存数据
    public function save()
    {
        return $this->userService->save();
    }

    //编辑
    public function edit($id)
    {
        $this->assign('info', $this->userService->edit($id));
        $this->assign('roles', config("rbac.RBAC_ROLES"));
        return $this->fetch();
    }

    //更新
    public function update()
    {
        return $this->userService->update();
    }

    //删除
    public function delete($id)
    {
        return $this->userService->delete($id);
    }


}